package com.wjk.kylin.mall.product.dto;

import com.alibaba.fastjson.JSONObject;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

/**
 * canal 消息格式
 * @author wjk
 */
@Data
public class CanalKafkaMessageDTO implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * {
     * "data":[{"id":"5","name":"5","code":"5"}],
     * "database":"canal_test_1",
     * "es":1644729358000,
     * "id":5,
     * "isDdl":false,
     * "mysqlType":{"id":"bigint","name":"varchar(255)",
     * "code":"varchar(255)"},
     * "old":null,
     * "pkNames":["id"],
     * "sql":"",
     * "sqlType":{"id":-5,"name":12,"code":12},
     * "table":"subject",
     * "ts":1644729358291,
     * "type":"INSERT"
     * }
     */

    //数据库名称
    private String database;
    //
    private long es;
    //递增，从1开始
    private int id;
    //是否是DDL语句
    private boolean ddl;
    //表结构的字段类型
    private JSONObject mysqlType;
    //UPDATE语句，旧数据
    //"old":[{"name":"2"}]
    private String old;
    //主键名称
    private List<String> pkNames;
    //sql语句 执行的sql，dml模式没有sql
    //  "sql": "CREATE DATABASE `ddl_test` CHARACTER SET \u0027utf8\u0027 COLLATE \u0027utf8_general_ci\u0027",
    private String sql;
    //
    private JSONObject sqlType;
    //表名
    private String table;
    //本次同步数据时间
    private long ts;
    //(新增)INSERT、(更新)UPDATE、(删除)DELETE、(删除表)ERASE等等
    private String type;

    //数据
    private List<JSONObject> data;
}
